package uit.bus;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class MapOverlay extends Overlay {

	public GeoPoint p;
	public Context context;

	public MapOverlay(GeoPoint p, Context context) {
		super();
		this.p = p;
		this.context = context;
	}

	@Override
	public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
			long when) {
		// TODO Auto-generated method stub
		super.draw(canvas, mapView, shadow, when);
		Point screen = new Point();
		mapView.getProjection().toPixels(p, screen);
		Bitmap my_location = BitmapFactory.decodeResource(
				context.getResources(), R.drawable.my_location);
		canvas.drawBitmap(my_location, screen.x - 19, screen.y - 19, null);

		return true;
	}

	@Override
	public boolean onTap(GeoPoint arg0, MapView arg1) {
		// TODO Auto-generated method stub

		Toast.makeText(context, "click item", Toast.LENGTH_LONG).show();
		return super.onTap(arg0, arg1);
	}

}
